faApp.controller('FinancierListCtrl', ['$scope', 'financierService', '$location', '$controller', '$route', function($scope, financierService, $location, $controller, $route) {
  $controller('BaseListCtrl', { $scope: $scope });

  $scope.config = {
    "pageSize": 20,
    "pageNo": 1
  };

  $scope.$watch('config', function() {
    financierService.financierList($scope.config).then(function(json){
      $scope.list = json.list;
      $scope.pager = json.pager;
    });
  }, true);  

  $scope.delete = function(id){
    if(id && confirm("确定要删除吗")){
      financierService.financierDelete({id: id}).then(function(json){
        if (json.statusCode){
          alert(json.statusCode);
        }else{
          alert("删除成功");
          $route.reload();
        }
      });
    }
  }
}]);

faApp.controller('FinancierAddCtrl', ['$scope', 'financierService', '$location', '$controller', '$route', function($scope, financierService, $location, $controller, $route) {
  $controller('BaseListCtrl', { $scope: $scope });

  $scope.financier = {};

  $scope.save = function(){
    if (!$scope.form.$invalid){
      financierService.financierAdd($scope.financier).then(function(json){
        if (json.statusCode){
          alert(json.statusCode);
        }else{
          alert("添加成功");
          $location.path("/financier/list");
        }
      });
    }
  };
}]);